package com.duoduo.mall.controller;

import java.util.Arrays;
import java.util.Map;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.duoduo.mall.entity.AdvertisementEntity;
import com.duoduo.mall.service.AdvertisementService;
import com.duoduo.mall.utils.PageUtils;
import com.duoduo.mall.utils.R;



/**
 * 广告表
 *
 * @author zhuge
 * @email 1399671339@qq.com
 * @date 2024-12-26 13:10:05
 */
@Api(tags = "广告接口")
@RestController
@RequestMapping("mall/advertisement")
public class AdvertisementController {
    @Autowired
    private AdvertisementService advertisementService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = advertisementService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 根据id查信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		AdvertisementEntity advertisement = advertisementService.getById(id);

        return R.ok().put("advertisement", advertisement);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody AdvertisementEntity advertisement){
		advertisementService.save(advertisement);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody AdvertisementEntity advertisement){
		advertisementService.updateById(advertisement);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		advertisementService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
